package com.example.appreciateorcomplain;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class WriteYourFeelingActivity extends Activity implements OnClickListener {
    public final static String sFeeing_Text = "com.poesia.appreciateorcomplain.FEELINGTEXT";
	Button appreciateButton;
	Button complainButton;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.writeyourfeeling);
		appreciateButton = (Button) findViewById( R.id.buttonAppreciate);
		appreciateButton.setOnClickListener(this);
		complainButton = (Button)findViewById( R.id.buttonComplain);
		complainButton.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v.getId() == R.id.buttonAppreciate )
		{
            //TODO: shenhe, this might change later,it's not a certain thing back to main
        	Intent intent = new Intent(this, MainActivity.class);
            EditText feelingText = (EditText) findViewById(R.id.editText);
            String strUserName = feelingText.getText().toString();
            intent.putExtra(sFeeing_Text,strUserName);
            startActivity(intent);
        }
		else if(v.getId() == R.id.buttonComplain)
		{
	        Intent intent=getIntent();
	        Bundle bundle=new Bundle();
            EditText feelingText = (EditText) findViewById(R.id.editText);
            String strUserName = feelingText.getText().toString();
	        bundle.putString(sFeeing_Text, strUserName);
	        intent.putExtras(bundle);
	        setResult(RESULT_OK, intent);
	        finish();// finish Activity
		}
	}
	

}
